(run_msdos_command): Make local copy of argv[2] on stack, not on heap.
authorKarl Heuer <kwzh@gnu.org>
Fri, 3 Jun 1994 04:50:17 +0000 (04:50 +0000)
committerKarl Heuer <kwzh@gnu.org>
Fri, 3 Jun 1994 04:50:17 +0000 (04:50 +0000)
(run_msdos_command): When changing argv[2] from using slashes to
using backslashes, only do so on the first white-space delimited part.

src/msdos.c

index 154ee1501c56c467d79a8a91b1fa7a45f7f349a9..fd9ae23efeecea89ae6761e2e28d289f90c7f325 100644 (file)
@@ -527,11 +527,20 @@ run_msdos_command (argv, dir, tempin, tempout)
   if (msshell)
     {
       saveargv1 = argv[1];
+      saveargv2 = argv[2];
       argv[1] = "/c";
       if (argv[2])
        {
-         saveargv2 = argv[2];
-         unixtodos_filename (argv[2] = strdup (argv[2]));
+         char *p = alloca (strlen (argv[2]) + 1);
+
+         strcpy (argv[2] = p, saveargv2);
+         while (*p && isspace (*p))
+           p++;
+         while (*p && !isspace (*p))
+           if (*p == '/')
+             *p++ = '\\';
+           else
+             p++;
        }
     }
 
@@ -578,11 +587,7 @@ run_msdos_command (argv, dir, tempin, tempout)
   if (msshell)
     {
       argv[1] = saveargv1;
-      if (argv[2])
-       {
-         free (argv[2]);
-         argv[2] = saveargv2;
-       }
+      argv[2] = saveargv2;
     }
   return result;
 }